﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Zore.App.Shared.Encryption
{
    /// <summary>
    /// Md5加密
    /// </summary>
    public static class Md5Encrypt
    { /// <summary>
      /// 32位md5加密
      /// </summary>
      /// <param name="text">明文</param>
      /// <returns></returns>
        public static string Encrypt(string text)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] t = md5.ComputeHash(Encoding.Default.GetBytes(text));
            StringBuilder sb = new StringBuilder(32);
            for (int i = 0; i < t.Length; i++)
            {
                sb.Append(t[i].ToString("x").PadLeft(2, '0'));
            }
            return sb.ToString();
        }
    }
}
